angular.module('masvida', ['ionic','ionic.service.core', 'masvida.controllers', 'masvida.services'])

.run(function ($ionicPlatform) {
    $ionicPlatform.ready(function () {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        }
        if (window.StatusBar) {
            // org.apache.cordova.statusbar required
            StatusBar.styleLightContent();
        }
    });
})

.config(function ($stateProvider, $urlRouterProvider) {

    // Ionic uses AngularUI Router which uses the concept of states
    // Learn more here: https://github.com/angular-ui/ui-router
    // Set up the various states which the app can be in.
    // Each state's controller can be found in controllers.js
    $stateProvider

    // setup an abstract state for the tabs directive
      .state('tab', {
          url: "/tab",
          abstract: true,
          templateUrl: "templates/tabs.html",
          controller: "TabCtrl"
      })


    .state('tab.attendance', {
        url: '/attendance',
        views: {
            'tab-attendance': {
                templateUrl: 'templates/tab-attendance.html',
                controller: 'AttendanceCtrl'
            }
        }
    })

      .state('tab.attendance-summary', {
          url: '/attendance/:groupId',
          views: {
              'tab-attendance': {
                  templateUrl: 'templates/tab-attendance-summary.html',
                  controller: 'AttendanceSummaryCtrl'
              }
          }
      })

    .state('tab.post-attendance', {
        url: '/postattendance/:attendanceSummaryId/:date/:met/:isPosted/:comments',
        views: {
            'tab-attendance': {
                templateUrl: 'templates/tab-post-attendance.html',
                controller: 'PostAttendanceCtrl'
            }
        }
    })

    .state('login', {
        url: '/login',
        templateUrl: 'templates/login.html',
        controller: 'LoginCtrl'
    });

    // if none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/login');

});
